﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;

public partial class News_DeclareList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gridbind();
            LoadTop10();
        }
    }
    protected void gridbind()
    {
        StringBuilder strSql = new StringBuilder();
        DataTable dt = new DataTable();
        strSql.AppendFormat("select btnname,plevel,ptype,opendate,closedate,inchargename,plancode from View_ProjectPlan where opendate<'{0}' and closedate>'{1}' order by type", DateTime.Now.ToString(), DateTime.Now.ToString());
        dt = PM.Code.DAL.DbHelper.GetPagedDataTable(strSql.ToString(), 20, AspNetPager1);
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

    protected void LoadTop10()
    {
        StringBuilder sb = new StringBuilder();
        StringBuilder strTable = new StringBuilder();
        sb.Append("select top 10 pname from Bus_Project where status='3' order by approvaldate desc");
        SqlDataReader reader = PM.Code.DAL.DbHelper.ExecuteDataReaderBySql(sb.ToString());
        strTable.Append("<ul>");
        while (reader.Read())
        {
            strTable.AppendFormat("<li>{0}</li>", reader[0].ToString());
        }
        strTable.Append("</ul>");
        if (reader.HasRows)
        {
            top10.InnerHtml = strTable.ToString();
        }
        else
        {
            top10.InnerHtml = "无最近立项的项目";
        }
        reader.Close();
    }


    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        gridbind();
    }
}
